﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DelegateEvent
{
    class CounterOneToTen2
    {
        public event EventHandler CountedToFive;

        public void StartCount()
        {
            for (int i = 1; i <= 10; i++)
            {
                System.Threading.Thread.Sleep(500);
                if (i == 5)
                {
                    OnCountedToFive(EventArgs.Empty);
                }
            }
        }

        protected void OnCountedToFive(EventArgs e)
        {
            if (CountedToFive != null)
            {
                CountedToFive(this, EventArgs.Empty);
            }
        }
    }
}
